/**
* @description: 二级 施工统计跳转 - 工程列表
* @author: JiWei
* @remark:
**/
<template>
  <view class="project-main">
    <nav-bar class="header" back title="工程列表" @goBack="goBack"/>
    <view class="project-content">
      <view class="not-service" v-if="taskList.length>0">
        <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
          <van-list v-model="isLoading" :finished="finished" finished-text="没有更多了" @load="loadMore">
            <view class="task-list"  v-for="(item,index) in taskList" :key="index" @click="jump(item,activeName)">
                <view class="task-text">
                  <img src="../../../static/controlImg/swgz.png" alt="">
                  <text>{{item.engName}}</text>
                </view>
            </view>
          </van-list>
        </van-pull-refresh>
      </view>
    </view>
  </view>
</template>
<script>
import navBar from "../../../components/common/nav-bar.vue";
import {mapGetters} from "vuex";
export default {
  name: 'projectList',
  components: { navBar},
  props: {
	 
  },
  data() {
    return {
      activeName:'notService',
      refreshing: false, // 是否正在刷新
      isLoading: false,
      finished: false,
      total: 0, // 总条数
      page: 1,
      limit: 10,
      taskList:[],
	  statusCode:null
    };
  },
  computed: {
	  ...mapGetters(['userData']),
  },
  watch: {},
  onLoad(option) {
	  if(option.name === '未开工'){
		  this.statusCode = 1;
	  }else if(option.name === '已开工'){
		  this.statusCode = 2;
	  }else{
		  this.statusCode = 3;
	  }
	  this.getLook();
  },
  methods: {
	getLook(){
	  let params = {
			page: this.page,
			row: this.limit,
			userId:this.userData.USERID,
			statusCode:this.statusCode
	  }
	  this.$apiRequest.gcgkApi.getLook(params).then(res => {
		
		this.isLoading = false;
		this.refreshing = false;
		this.taskList = this.taskList.concat(res.data.engs);
		this.total = res.data.total;
	  })
	},
    goBack() {
      uni.navigateTo({
        url: '/pages/communicationControl/index/index'
      })
    },
    onRefresh() {
      this.refreshing = true;
      this.finished = false;
      this.page = 1;
      this.taskList = [];
	  this.getLook();
    },
    loadMore() {
      if (this.total > this.taskList.length) {
        this.page = this.page + 1;
		this.getLook();
      } else {
        this.finished = true;
      }
    },
    jump(item){
		let options = null;
		if(this.statusCode === 1){ // notService 未开工
			options = JSON.stringify({
				engId:item.objId,
				type:"notService"
			})
		}else if(this.statusCode === 2){ // inService 已开工
			options = JSON.stringify({
				engId:item.objId,
				type:"inService"
			})
		}else{ // completed 已完工
			options = JSON.stringify({
				engId:item.objId,
				type:"completed"
			})
		}
		uni.navigateTo({
			url:`/pages/communicationControl/workbench/projectList/projectDetails?options=${encodeURIComponent(options)}`
		})
		
    }
  }
};
</script>
<style scoped lang="scss">
.project-main {
  width: 100vw;
  height: 100vh;
  background: #F2F6FA;
  .project-content {
    width: 100vw;
    height: calc(100vh - #{px2vh(184)});
    overflow: hidden;
    .not-service {
      width: calc(100vw - #{px2vw(60)});
      margin-left: px2vw(30);
      height: calc(100vh - #{px2vh(300)});
      margin-top: px2vh(74);
      overflow: auto;
      .task-list {
        height: px2vh(140);
        background: #fff;
        border-radius: px2vw(20);
        margin-bottom: px2vh(30);
        .task-text {
          padding: px2vh(40) px2vw(40);
          font-size: px2vh(42);
          overflow: hidden;
          text-overflow:ellipsis;
          white-space: nowrap;
          img {
            width: px2vw(64);
            margin-right: px2vw(20);
            vertical-align: middle;
          }
        }
        .delBtn {
          height: 100%;
          background: #FF4355;
          border-radius: px2vw(0) px2vw(20) px2vw(20) px2vw(0);
        }
      }
    }
  }
}
</style>
